home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / GMS / GMSDev / Includes / lib / dpk.s < prev   
Encoding:
Text File  |  1998-04-27  |  3.7 KB  |  176 lines

  1. ;=======T=======T========================T==========================================;
  2. ;Name:      DPKernel start-up file.
  3. ;Author:    Paul Manias.
  4. ;Date:      February 1998
  5. ;Copyright: DreamWorld Productions (c) 1996-1998.  All rights reserved.
  6.  
  7.     INCDIR    "INCLUDES:"
  8.     INCLUDE    "dpkernel/dpkernel.i"
  9.     INCLUDE    "system/tasks.i"
  10.  
  11.     xref    _main
  12.     xref    _ProgVersion
  13.     xref    _ProgRevision
  14.     xref    _ProgAuthor
  15.     xref    _ProgCopyright
  16.     xref    _ProgDate
  17.     xref    _ProgName
  18.     xref    _ProgShort
  19.  
  20.     xdef    _Args
  21.     xdef    _BLTBase
  22.     xdef    _DPKBase
  23.     xdef    _FILBase
  24.     xdef    _GVBase
  25.     xdef    _SCRBase
  26.     xdef    _SNDBase
  27.     xdef    _BLTModule
  28.     xdef    _FILModule
  29.     xdef    _SCRModule
  30.     xdef    _SNDModule
  31.     xdef    _SysBase
  32.     xdef    _Table
  33.     xdef    __XCEXIT
  34.  
  35.     SECTION    "DPKStart",CODE
  36.  
  37. ;===================================================================================;
  38. ;                            SPECIAL STARTUP CODE
  39. ;===================================================================================;
  40.  
  41. Start:    bra.s    StartAmigaDOS
  42.  
  43. _Table:    dc.l    "PRGM"    ;ID Header.
  44.     dc.w    1    ;Version number.
  45.     dc.w    JMP_LVO    ;Type of jump table to get from DPK.
  46.     dc.l    StartDPKernel    ;Start of program.
  47.     dc.l    _ProgName    ;Name of the program.
  48.     dc.l    _ProgAuthor    ;Who wrote the program.
  49.     dc.l    _ProgDate    ;Date of compilation.
  50.     dc.l    _ProgCopyright    ;Copyright details.
  51.     dc.l    _ProgShort    ;Short description of program.
  52.     dc.w    DPKVersion    ;Minimum required DPKernel version.
  53.     dc.w    DPKRevision    ;Minimum required DPKernel revision.
  54.  
  55. StartDPKernel:
  56.     MOVEM.L    D0-D7/A0-A6,-(SP)
  57.     move.l    ($4).w,_SysBase
  58.     move.l    GT_DPKBase(a0),_DPKBase
  59.     move.l    GT_DPKBase(a0),_GVBase
  60.     bra.s    Launch
  61.  
  62. StartAmigaDOS
  63.     MOVEM.L    D0-D7/A0-A6,-(SP)
  64.     move.l    ($4).w,_SysBase
  65.  
  66. .Check    move.l    _SysBase(pc),a6
  67.     sub.l    a1,a1
  68.     jsr    -294(a6)    ;>> = FindTask
  69.     move.l    d0,a4
  70.     tst.l    172(a4)    ;a4 = pr_CLI
  71.     bne.s    .DOS
  72.  
  73. .WBench    lea    92(a4),a0    ;a0 = pr_MsgPort
  74.     jsr    -384(a6)    ;>> = WaitPort()
  75.  
  76.     lea    92(a4),a0    ;a0 = pr_MsgPort
  77.     jsr    -372(a6)    ;>> = GetMsg()
  78.     move.l    d0,ReturnMsg    ;ma = Store message.
  79.  
  80. .DOS    move.l    _SysBase(pc),a6    ;a6 = ExecBase
  81.     lea    DPKName(pc),a1    ;a1 = Library name.
  82.     moveq    #$00,d0    ;d0 = Any version.
  83.     jsr    -552(a6)    ;>> = OpenLibrary()
  84.     move.l    d0,_GVBase    ;ma = Save global variable base.
  85.     move.l    d0,_DPKBase    ;ma = Save base.
  86.     beq.s    ErrDPK    ;>> = Error, exit.
  87.     move.w    #1,DOS
  88.  
  89.     move.l    d0,a6    ;a6 = DPKBase.
  90.     lea    Exit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  91.     move.l    a7,a1    ;a1 = Stack pointer.
  92.     CALL    InitDestruct    ;>> = Initialise the call.
  93.  
  94. Launch:    move.l    _DPKBase(pc),a6
  95.     moveq    #MOD_SCREENS,d0
  96.     sub.l    a0,a0
  97.     CALL    OpenModule
  98.     move.l    d0,_SCRModule
  99.     beq.s    Exit
  100.     move.l    d0,a5
  101.     move.l    MOD_ModBase(a5),_SCRBase
  102.  
  103.     moveq    #MOD_SOUND,d0
  104.     sub.l    a0,a0
  105.     CALL    OpenModule
  106.     move.l    d0,_SNDModule
  107.     beq.s    Exit
  108.     move.l    d0,a5
  109.     move.l    MOD_ModBase(a5),_SNDBase
  110.  
  111.     moveq    #MOD_BLITTER,d0
  112.     sub.l    a0,a0
  113.     CALL    OpenModule
  114.     move.l    d0,_BLTModule
  115.     beq.s    Exit
  116.     move.l    d0,a5
  117.     move.l    MOD_ModBase(a5),_BLTBase
  118.  
  119.     moveq    #MOD_FILES,d0
  120.     sub.l    a0,a0
  121.     CALL    OpenModule
  122.     move.l    d0,_FILModule
  123.     beq.s    Exit
  124.     move.l    d0,a5
  125.     move.l    MOD_ModBase(a5),_FILBase
  126.  
  127.     move.l    _DPKBase(pc),a6
  128.     jsr    _main
  129.  
  130. __XCEXIT:
  131. Exit:    move.l    _DPKBase(pc),a6    ;a6 = DPKBase
  132.     move.l    _FILModule(pc),a0
  133.     CALL    Free
  134.     move.l    _SCRModule(pc),a0
  135.     CALL    Free
  136.     move.l    _BLTModule(pc),a0
  137.     CALL    Free
  138.     move.l    _SNDModule(pc),a0
  139.     CALL    Free
  140.  
  141.     tst.w    DOS
  142.     beq.s    ProgEnd
  143.     CALL    CloseDPK
  144.  
  145.     move.l    ReturnMsg(pc),d0
  146.     beq.s    ProgEnd
  147.     move.l    _SysBase(pc),a6
  148.     jsr    -378(a6)
  149.  
  150. ProgEnd:
  151. ErrDPK:    MOVEM.L    (SP)+,D0-D7/A0-A6
  152.     moveq    #$00,d0
  153.     rts
  154.  
  155. DOS:        dc.w  0
  156. ReturnMsg:    dc.l  0
  157.  
  158. _BLTBase:    dc.l  0
  159. _FILBase:    dc.l  0
  160. _SCRBase:    dc.l  0
  161. _SNDBase:    dc.l  0
  162. _SysBase:    dc.l  0
  163.  
  164. _BLTModule:    dc.l  0
  165. _FILModule:    dc.l  0
  166. _SCRModule:    dc.l  0
  167. _SNDModule:    dc.l  0
  168.  
  169. _DPKBase:    dc.l  0    ;DPKBase.
  170. _GVBase:    dc.l  0     ;Global variable base.
  171. _Args:        dc.l  0    ;Pointer to argument string.
  172.  
  173. DPKName:    dc.b  "GMS:libs/dpkernel.library",0
  174.         even
  175.  
  176.